home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / TextServices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  12.4 KB  |  322 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        TextServices.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __TEXTSERVICES__
  18. #define __TEXTSERVICES__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __EVENTS__
  27. #include <Events.h>
  28. #endif
  29. /*    #include <Quickdraw.h>                                        */
  30. /*        #include <MixedMode.h>                                    */
  31. /*        #include <QuickdrawText.h>                                */
  32. /*    #include <OSUtils.h>                                        */
  33. /*        #include <Memory.h>                                        */
  34.  
  35. #ifndef __MENUS__
  36. #include <Menus.h>
  37. #endif
  38.  
  39. #ifndef __APPLEEVENTS__
  40. #include <AppleEvents.h>
  41. #endif
  42. /*    #include <Errors.h>                                            */
  43. /*    #include <EPPC.h>                                            */
  44. /*        #include <PPCToolbox.h>                                    */
  45. /*            #include <AppleTalk.h>                                */
  46. /*        #include <Processes.h>                                    */
  47. /*            #include <Files.h>                                    */
  48. /*    #include <Notification.h>                                    */
  49.  
  50. #ifndef __COMPONENTS__
  51. #include <Components.h>
  52. #endif
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. #if GENERATINGPOWERPC
  59. #pragma options align=mac68k
  60. #endif
  61.  
  62. #ifdef __CFM68K__
  63. #pragma lib_export on
  64. #endif
  65.  
  66.  
  67. enum {
  68.     kTSMVersion                    = 0x200,                        /* Version of the Text Services Manager is 2.0  */
  69.     kTextService                = 'tsvc',                        /* component type for the component description */
  70.     kInputMethodService            = 'inpm',                        /* component subtype for the component description */
  71. /* Component Flags in ComponentDescription */
  72.     bTakeActiveEvent            = 15,                            /* bit set if the component takes active event */
  73.     bHandleAERecording            = 16,                            /* bit set if the component takes care of recording Apple Events <new in vers2.0> */
  74.     bScriptMask                    = 0x00007F00,                    /* bit 8 - 14 */
  75.     bLanguageMask                = 0x000000FF,                    /* bit 0 - 7  */
  76.     bScriptLanguageMask            = bScriptMask + bLanguageMask    /* bit 0 - 14  */
  77. };
  78.  
  79. enum {
  80. /* Hilite styles */
  81.     kCaretPosition                = 1,                            /* specify caret position */
  82.     kRawText                    = 2,                            /* specify range of raw text */
  83.     kSelectedRawText            = 3,                            /* specify range of selected raw text */
  84.     kConvertedText                = 4,                            /* specify range of converted text */
  85.     kSelectedConvertedText        = 5                                /* specify range of selected converted text */
  86. };
  87.  
  88. /* Apple Event constants */
  89. enum {
  90. /* Event class */
  91.     kTextServiceClass            = kTextService,
  92. /* event ID */
  93.     kUpdateActiveInputArea        = 'updt',                        /* update the active Inline area */
  94.     kPos2Offset                    = 'p2st',                        /* converting global coordinates to char position */
  95.     kOffset2Pos                    = 'st2p',                        /* converting char position to global coordinates */
  96.     kShowHideInputWindow        = 'shiw',                        /* show or hide the input window */
  97. /* Event keywords */
  98.     keyAETSMDocumentRefcon        = 'refc',                        /* TSM document refcon, typeLongInteger */
  99. /* Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  100.     typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  101.     AERegistry.h */
  102.     keyAEServerInstance            = 'srvi',                        /* component instance */
  103.     keyAETheData                = 'kdat',                        /* typeText */
  104.     keyAEFixLength                = 'fixl',                        /* fix len ?? */
  105.     keyAEHiliteRange            = 'hrng',                        /* hilite range array */
  106.     keyAEUpdateRange            = 'udng',                        /* update range array */
  107.     keyAEClauseOffsets            = 'clau',                        /* Clause Offsets array */
  108.     keyAECurrentPoint            = 'cpos',                        /* current point */
  109.     keyAEDragging                = 'bool',                        /* dragging falg */
  110.     keyAEOffset                    = 'ofst',                        /* offset */
  111.     keyAERegionClass            = 'rgnc',                        /* region class */
  112.     keyAEPoint                    = 'gpos',                        /* current point */
  113.     keyAEBufferSize                = 'buff',                        /* buffer size to get the text */
  114.     keyAEMoveView                = 'mvvw',                        /* move view flag */
  115.     keyAELength                    = 'leng',                        /* length */
  116.     keyAENextBody                = 'nxbd',                        /* next or previous body */
  117. /* optional keywords for Offset2Pos (Info about the active input area) */
  118.     keyAETextLineHeight            = 'ktlh',                        /* typeShortInteger */
  119.     keyAETextLineAscent            = 'ktas',                        /* typeShortInteger */
  120. /* optional keywords for Pos2Offset */
  121.     keyAELeftSide                = 'klef',                        /* type Boolean */
  122. /* optional keywords for kShowHideInputWindow */
  123.     keyAEShowHideInputWindow    = 'shiw',                        /* type Boolean */
  124. /* for PinRange  */
  125.     keyAEPinRange                = 'pnrg',
  126. /* Desc type ... */
  127.     typeComponentInstance        = 'cmpi',                        /* server instance */
  128.     typeTextRangeArray            = 'tray',                        /* text range array */
  129.     typeOffsetArray                = 'ofay',                        /* offset array */
  130.     typeText                    = 'TEXT',                        /* Plain text */
  131.     typeTextRange                = 'txrn'
  132. };
  133.  
  134. /* Desc type constants */
  135. enum {
  136.     kTSMOutsideOfBody            = 1,
  137.     kTSMInsideOfBody            = 2,
  138.     kTSMInsideOfActiveInputArea    = 3
  139. };
  140.  
  141. enum {
  142.     kNextBody                    = 1,
  143.     kPreviousBody                = 2
  144. };
  145.  
  146. /* typeTextRange         'txrn' */
  147. struct TextRange {
  148.     long                            fStart;
  149.     long                            fEnd;
  150.     short                            fHiliteStyle;
  151. };
  152. typedef struct TextRange TextRange;
  153.  
  154. typedef TextRange *TextRangePtr;
  155.  
  156. typedef TextRangePtr *TextRangeHandle;
  157.  
  158. /* typeTextRangeArray    'txra' */
  159. struct TextRangeArray {
  160.     short                            fNumOfRanges;                /* specify the size of the fRange array */
  161.     TextRange                        fRange[1];                    /* when fNumOfRanges > 1, the size of this array has to be calculated */
  162. };
  163. typedef struct TextRangeArray TextRangeArray;
  164.  
  165. typedef TextRangeArray *TextRangeArrayPtr;
  166.  
  167. typedef TextRangeArrayPtr *TextRangeArrayHandle;
  168.  
  169. /* typeOffsetArray        'offa' */
  170. struct OffsetArray {
  171.     short                            fNumOfOffsets;                /* specify the size of the fOffset array */
  172.     long                            fOffset[1];                    /* when fNumOfOffsets > 1, the size of this array has to be calculated */
  173. };
  174. typedef struct OffsetArray OffsetArray;
  175.  
  176. typedef OffsetArray *OffsetArrayPtr;
  177.  
  178. typedef OffsetArrayPtr *OffsetArrayHandle;
  179.  
  180. #define mGetScriptCode(cdRec) ((ScriptCode)    ((cdRec.componentFlags & bScriptMask) >> 8))
  181. #define mGetLanguageCode(cdRec) ((LangCode)    cdRec.componentFlags & bLanguageMask)
  182. typedef void *TSMDocumentID;
  183.  
  184. typedef OSType InterfaceTypeList[1];
  185.  
  186. /* Text Service Info List */
  187. struct TextServiceInfo {
  188.     Component                        fComponent;
  189.     Str255                            fItemName;
  190. };
  191. typedef struct TextServiceInfo TextServiceInfo;
  192.  
  193. typedef TextServiceInfo *TextServiceInfoPtr;
  194.  
  195. struct TextServiceList {
  196.     short                            fTextServiceCount;            /* number of entries in the 'fServices' array */
  197.     TextServiceInfo                    fServices[1];                /* Note: array of 'TextServiceInfo' records follows */
  198. };
  199. typedef struct TextServiceList TextServiceList;
  200.  
  201. typedef TextServiceList *TextServiceListPtr;
  202.  
  203. typedef TextServiceListPtr *TextServiceListHandle;
  204.  
  205. struct ScriptLanguageRecord {
  206.     ScriptCode                        fScript;
  207.     LangCode                        fLanguage;
  208. };
  209. typedef struct ScriptLanguageRecord ScriptLanguageRecord;
  210.  
  211. struct ScriptLanguageSupport {
  212.     short                            fScriptLanguageCount;        /* number of entries in the 'fScriptLanguageArray' array */
  213.     ScriptLanguageRecord            fScriptLanguageArray[1];    /* Note: array of 'ScriptLanguageRecord' records follows */
  214. };
  215. typedef struct ScriptLanguageSupport ScriptLanguageSupport;
  216.  
  217. typedef ScriptLanguageSupport *ScriptLanguageSupportPtr;
  218.  
  219. typedef ScriptLanguageSupportPtr *ScriptLanguageSupportHandle;
  220.  
  221.  
  222. enum {
  223. /* Low level routines which are dispatched directly to the Component Manager */
  224.     kCMGetScriptLangSupport        = 0x0001,                        /* Component Manager call selector 1 */
  225.     kCMInitiateTextService        = 0x0002,                        /* Component Manager call selector 2 */
  226.     kCMTerminateTextService        = 0x0003,                        /* Component Manager call selector 3 */
  227.     kCMActivateTextService        = 0x0004,                        /* Component Manager call selector 4 */
  228.     kCMDeactivateTextService    = 0x0005,                        /* Component Manager call selector 5 */
  229.     kCMTextServiceEvent            = 0x0006,                        /* Component Manager call selector 6 */
  230.     kCMGetTextServiceMenu        = 0x0007,                        /* Component Manager call selector 7 */
  231.     kCMTextServiceMenuSelect    = 0x0008,                        /* Component Manager call selector 8 */
  232.     kCMFixTextService            = 0x0009,                        /* Component Manager call selector 9 */
  233.     kCMSetTextServiceCursor        = 0x000A,                        /* Component Manager call selector 10 */
  234.     kCMHidePaletteWindows        = 0x000B                        /* Component Manager call selector 11 */
  235. };
  236.  
  237. /* High level TSM routines */
  238. extern pascal OSErr NewTSMDocument(short numOfInterface, InterfaceTypeList supportedInterfaceTypes, TSMDocumentID *idocID, long refcon)
  239.  TWOWORDINLINE(0x7000, 0xAA54);
  240. extern pascal OSErr DeleteTSMDocument(TSMDocumentID idocID)
  241.  TWOWORDINLINE(0x7001, 0xAA54);
  242. extern pascal OSErr ActivateTSMDocument(TSMDocumentID idocID)
  243.  TWOWORDINLINE(0x7002, 0xAA54);
  244. extern pascal OSErr DeactivateTSMDocument(TSMDocumentID idocID)
  245.  TWOWORDINLINE(0x7003, 0xAA54);
  246. extern pascal Boolean TSMEvent(EventRecord *event)
  247.  TWOWORDINLINE(0x7004, 0xAA54);
  248. extern pascal Boolean TSMMenuSelect(long menuResult)
  249.  TWOWORDINLINE(0x7005, 0xAA54);
  250. extern pascal Boolean SetTSMCursor(Point mousePos)
  251.  TWOWORDINLINE(0x7006, 0xAA54);
  252. extern pascal OSErr FixTSMDocument(TSMDocumentID idocID)
  253.  TWOWORDINLINE(0x7007, 0xAA54);
  254. extern pascal OSErr GetServiceList(short numOfInterface, OSType *supportedInterfaceTypes, TextServiceListHandle *serviceInfo, long *seedValue)
  255.  TWOWORDINLINE(0x7008, 0xAA54);
  256. extern pascal OSErr OpenTextService(TSMDocumentID idocID, Component aComponent, ComponentInstance *aComponentInstance)
  257.  TWOWORDINLINE(0x7009, 0xAA54);
  258. extern pascal OSErr CloseTextService(TSMDocumentID idocID, ComponentInstance aComponentInstance)
  259.  TWOWORDINLINE(0x700A, 0xAA54);
  260. extern pascal OSErr SendAEFromTSMComponent(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc)
  261.  TWOWORDINLINE(0x700B, 0xAA54);
  262. extern pascal OSErr InitTSMAwareApplication(void)
  263.  TWOWORDINLINE(0x7014, 0xAA54);
  264. extern pascal OSErr CloseTSMAwareApplication(void)
  265.  TWOWORDINLINE(0x7015, 0xAA54);
  266. /* Utilities */
  267. extern pascal OSErr SetDefaultInputMethod(Component ts, ScriptLanguageRecord *slRecordPtr)
  268.  TWOWORDINLINE(0x700C, 0xAA54);
  269. extern pascal OSErr GetDefaultInputMethod(Component *ts, ScriptLanguageRecord *slRecordPtr)
  270.  TWOWORDINLINE(0x700D, 0xAA54);
  271. extern pascal OSErr SetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  272.  TWOWORDINLINE(0x700E, 0xAA54);
  273. extern pascal OSErr GetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  274.  TWOWORDINLINE(0x700F, 0xAA54);
  275. extern pascal OSErr UseInputWindow(TSMDocumentID idocID, Boolean useWindow)
  276.  TWOWORDINLINE(0x7010, 0xAA54);
  277. extern pascal OSErr NewServiceWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, ComponentInstance ts, WindowPtr *window)
  278.  TWOWORDINLINE(0x7011, 0xAA54);
  279. extern pascal OSErr CloseServiceWindow(WindowPtr window)
  280.  TWOWORDINLINE(0x7012, 0xAA54);
  281. extern pascal OSErr GetFrontServiceWindow(WindowPtr *window)
  282.  TWOWORDINLINE(0x7013, 0xAA54);
  283. extern pascal short FindServiceWindow(Point thePoint, WindowPtr *theWindow)
  284.  TWOWORDINLINE(0x7017, 0xAA54);
  285. /* Low level TSM routines */
  286. extern pascal ComponentResult GetScriptLanguageSupport(ComponentInstance ts, ScriptLanguageSupportHandle *scriptHdl)
  287.  FIVEWORDINLINE(0x2F3C, 0x04, 0x0001, 0x7000, 0xA82A);
  288. extern pascal ComponentResult InitiateTextService(ComponentInstance ts)
  289.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0002, 0x7000, 0xA82A);
  290. extern pascal ComponentResult TerminateTextService(ComponentInstance ts)
  291.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0003, 0x7000, 0xA82A);
  292. extern pascal ComponentResult ActivateTextService(ComponentInstance ts)
  293.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0004, 0x7000, 0xA82A);
  294. extern pascal ComponentResult DeactivateTextService(ComponentInstance ts)
  295.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0005, 0x7000, 0xA82A);
  296. extern pascal ComponentResult TextServiceEvent(ComponentInstance ts, short numOfEvents, EventRecord *event)
  297.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0006, 0x7000, 0xA82A);
  298. extern pascal ComponentResult GetTextServiceMenu(ComponentInstance ts, MenuHandle *serviceMenu)
  299.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0007, 0x7000, 0xA82A);
  300. extern pascal ComponentResult TextServiceMenuSelect(ComponentInstance ts, MenuHandle serviceMenu, short item)
  301.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0008, 0x7000, 0xA82A);
  302. extern pascal ComponentResult FixTextService(ComponentInstance ts)
  303.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0009, 0x7000, 0xA82A);
  304. extern pascal ComponentResult SetTextServiceCursor(ComponentInstance ts, Point mousePos)
  305.  FIVEWORDINLINE(0x2F3C, 0x04, 0x000A, 0x7000, 0xA82A);
  306. extern pascal ComponentResult HidePaletteWindows(ComponentInstance ts)
  307.  FIVEWORDINLINE(0x2F3C, 0x00, 0x000B, 0x7000, 0xA82A);
  308.  
  309. #ifdef __CFM68K__
  310. #pragma lib_export off
  311. #endif
  312.  
  313. #if GENERATINGPOWERPC
  314. #pragma options align=reset
  315. #endif
  316.  
  317. #ifdef __cplusplus
  318. }
  319. #endif
  320.  
  321. #endif /* __TEXTSERVICES__ */
  322.